package com.monitor.action.user;

import com.monitor.action.MonitorActionSupport;
import com.monitor.service.SettingService;
import com.monitor.util.CommenUtil;

public class SettingAction extends MonitorActionSupport {

	private static final long serialVersionUID = 1L;
	private String upSms;
	private String upLocation;
	private String upCalllog;
	private SettingService settingService;

	@Override
	public String execute() throws Exception {
		upSms = settingService.isUploadSms();
		upLocation = settingService.isUploadLocation();
		upCalllog = settingService.isUploadCallLog();
		return SUCCESS;
	}

	public String submitSetting() throws Exception {
		upSms = CommenUtil.isEmpty(upSms) ? "0" : "1";
		upCalllog = CommenUtil.isEmpty(upCalllog) ? "0" : "1";
		upLocation = CommenUtil.isEmpty(upLocation) ? "0" : "1";
		settingService.set(upSms, upCalllog, upLocation);
		addFieldError("id", getText("setting.success"));
		return SUCCESS;
	}

	public String getUpSms() {
		return upSms;
	}

	public void setUpSms(String upSms) {
		this.upSms = upSms;
	}

	public String getUpLocation() {
		return upLocation;
	}

	public void setUpLocation(String upLocation) {
		this.upLocation = upLocation;
	}

	public String getUpCalllog() {
		return upCalllog;
	}

	public void setUpCalllog(String upCalllog) {
		this.upCalllog = upCalllog;
	}

	public SettingService getSettingService() {
		return settingService;
	}

	public void setSettingService(SettingService settingService) {
		this.settingService = settingService;
	}

}
